package com.zhangdi.mgsync.core.config;

import com.zhangdi.mgsync.core.message.EmailUtil;
import com.zhangdi.mgsync.core.rabbit.AdminTemplate;
import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhangdi
 * @version 1.0
 * @date 2021.11.3 15:33
 */
@Configuration
public class RabbitMQConfiguration {
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

    @Bean("onlineAdminTemplate")
    AdminTemplate onlineAdminTemplate(RabbitTemplate rabbitTemplate, AmqpAdmin amqpAdmin, EmailUtil emailUtil){
        return new AdminTemplate(rabbitTemplate, amqpAdmin, emailUtil);
    }

    @Bean("tenderAdminTemplate")
    AdminTemplate tenderAdminTemplate(RabbitTemplate rabbitTemplate, AmqpAdmin amqpAdmin, EmailUtil emailUtil){
        return new AdminTemplate(rabbitTemplate, amqpAdmin, emailUtil);
    }

    @Bean("standardAdminTemplate")
    AdminTemplate standardAdminTemplate(RabbitTemplate rabbitTemplate, AmqpAdmin amqpAdmin, EmailUtil emailUtil){
        return new AdminTemplate(rabbitTemplate, amqpAdmin, emailUtil);
    }
}
